package com.xdcplus.web.controller;



import com.xdcplus.mom.controller.AbstractController;
import com.xdcplus.exceptions.domain.ResponseVO;

import com.xdcplus.pager.vo.PageVO;
import com.xdcplus.web.common.pojo.dto.CraftCheckOrderItemsDTO;
import com.xdcplus.web.common.pojo.dto.CraftCheckOrderItemsFilterDTO;
import com.xdcplus.web.common.pojo.vo.CraftCheckOrderItemsVO;
import com.xdcplus.web.service.CraftCheckOrderItemsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Validation;
import javax.validation.constraints.NotNull;


/**
 * 点检工单点检项明细表(CraftCheckOrderItems)表服务控制层
 *
 * @author Man.Chen
 * @since 2024-12-03 17:56:21
 */
@Api(tags = "点检工单点检项明细表(CraftCheckOrderItems)") 
@Slf4j
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("craftCheckOrderItems")
public class CraftCheckOrderItemsController extends AbstractController {

    @Autowired
    private CraftCheckOrderItemsService craftCheckOrderItemsService;

    @ApiOperation("新增点检工单点检项明细表")
    @PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO saveCraftCheckOrderItems(@RequestBody CraftCheckOrderItemsDTO craftCheckOrderItemsDTO) {

        log.info("saveCraftCheckOrderItems {}", craftCheckOrderItemsDTO.toString());

        craftCheckOrderItemsDTO.setCreatedUser(getAccount());
        craftCheckOrderItemsService.saveCraftCheckOrderItems(craftCheckOrderItemsDTO);

        return ResponseVO.success();
    }

    @ApiOperation("修改点检工单点检项明细表")
    @PutMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO updateCraftCheckOrderItems(@RequestBody CraftCheckOrderItemsDTO craftCheckOrderItemsDTO) {

        log.info("updateCraftCheckOrderItems {}", craftCheckOrderItemsDTO.toString());

        craftCheckOrderItemsDTO.setUpdatedUser(getAccount());
        craftCheckOrderItemsService.updateCraftCheckOrderItems(craftCheckOrderItemsDTO);

        return ResponseVO.success();
    }

    @ApiOperation("删除点检工单点检项明细表")
    @DeleteMapping(value = "/{craftCheckOrderItemsId}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "craftCheckOrderItemsId", dataTypeClass = Long.class, value = "点检工单点检项明细表ID", required = true),
    })
    public ResponseVO deleteCraftCheckOrderItemsLogical(@PathVariable("craftCheckOrderItemsId")
                                         @NotNull(message = "点检工单点检项明细表ID不能为空") Long craftCheckOrderItemsId) {

        log.info("deleteCraftCheckOrderItemsLogical {}", craftCheckOrderItemsId);

        craftCheckOrderItemsService.deleteCraftCheckOrderItemsLogical(craftCheckOrderItemsId);

        return ResponseVO.success();
    }
    
    @ApiOperation("批量删除点检工单点检项明细表")
    @DeleteMapping(value = "/deleteByIds/{craftCheckOrderItemsIds}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "craftCheckOrderItemsId", dataTypeClass = Long.class, value = "点检工单点检项明细表ID", required = true),
    })
    public ResponseVO deleteCraftCheckOrderItemsLogical(@PathVariable("craftCheckOrderItemsIds")
                                         @NotNull(message = "点检工单点检项明细表ID不能为空") String craftCheckOrderItemsIds) {

        log.info("deleteCraftCheckOrderItemsByIds {}", craftCheckOrderItemsIds);

        craftCheckOrderItemsService.deleteCraftCheckOrderItemsByIds(craftCheckOrderItemsIds);

        return ResponseVO.success();
    }

    @ApiOperation("查询点检工单点检项明细表")
    @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<PageVO<CraftCheckOrderItemsVO>> findCraftCheckOrderItems(CraftCheckOrderItemsFilterDTO craftCheckOrderItemsFilterDTO) {

        log.info("findCraftCheckOrderItems {}", craftCheckOrderItemsFilterDTO);

        Validation.buildDefaultValidatorFactory().getValidator().validate(craftCheckOrderItemsFilterDTO);

        return ResponseVO.success(craftCheckOrderItemsService.queryCraftCheckOrderItems(craftCheckOrderItemsFilterDTO));
    }


}
